package com.example.lanqiaodemo1.TestFour;

import com.example.lanqiaodemo1.TestFour.Account;

//Account的子类信用卡账户类
public class CreditCardAccount extends Account {
    private double overdraftMoney;
    public void setOverdraftMoney(double overdraftMoney){
        this.overdraftMoney=overdraftMoney;
    }
    public double getOverdraftMoney(){
        return overdraftMoney;
    }
    public CreditCardAccount(String id,String name,double balance,double overdraftMoney){
        super(id,name,balance);
        this.overdraftMoney=overdraftMoney;
    }
    @Override
    public void withdraw(double money){
        if(money>(this.getBalance()+this.overdraftMoney)){
            System.out.println("支取金额超过了限度，不能支取");
        }
        this.setBalance(this.getBalance()-money);
    }
    @Override
    public void changeMoney(Account other,double money){
        if(money>(this.getBalance()+overdraftMoney)){
            System.out.println("转账金额超过了限度，不能转账");
        }
        this.setBalance(this.getBalance()-money);
        other.setBalance(other.getBalance()+money);
    }
}
